<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>  
<c:set var="contextPath" value="<%=request.getContextPath()%>"></c:set> 
<!DOCTYPE html>
<html lang="en">
<head>
	<title>Tables - Ace Admin</title>
	
	<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/ajaxfileupload.js"></script>


	<script type="text/javascript">
	$(function(){
		
		//确认是否删除
		$(".del").click(function(){
			if(confirm("是否确认能删除？")){
				return true;
			}else{
				return false;
			}
		});
		
		
		//弹出批量增加学生模态框
		$('#batchAddStudentBtn').click(function(){
			$('#uploadFileModal').modal('show');
		})
		
		//显示上传控制样式
		$('#uploadFile').ace_file_input({
			style:'well',
			btn_choose:'Drop files here or click to choose',
			btn_change:null,
			no_icon:'ace_icon fa fa-clound-upload',
			droppable:true,
			thumbnail:'samll',//large | fit
			preview_error:function(filename,error_code){
			}
		}).on('change',function(){
			//console.log($(this).data('ace_input_files'));
			//console.log($(this).data('ace_input_method'));
		});
		
		//保存并导入Excel数据进行批量添加学生
		$('#subjectStudentSaveBtn').on('click',function(){
			$.ajaxFileUpload({
				url:'${contextPath}/teacher/uploadFile', //用于文件上传的服务器端请求地址
				secureuri:false,				//一般设置为false
				fileElementId:'uploadFile',		//文件上传控件的id属性<input id="uploadFile" name="uploadFile" type="file"/>
				dataType:'json',				//返回值一般设置为json
				complete:function(data){		//只要完成即执行，最后执行
					//alert(data);
				},
				success:function(data,status){//服务器成功响应处理函数
					if(data.success){
						alert('成功');
						window.location.reload();
					}else{
						alert(data.messageMap.message);
					}
				},
				errror:function(data,status,e){//服务器响应失败处理函数
					alert(e);
				}
			});
		});
		
	});
	
	</script>
	
</head>
<body class="no-skin">
	<!-- /section:settings.box -->
	<div class="page-content-area">
		<a href="add" id="addStudentBtn" class="btn btn-primary"><i class="ace-icon fa fa-plus ">&nbsp;&nbsp;添加学生信息</i></a>
		<button id="batchAddStudentBtn" class="btn btn-primary"><i class="ace-icon fa fa-plus">&nbsp;&nbsp;批量添加学生信息</i></button>
		<div class="row">
			<div class="col-xs-12">
				<!-- PAGE CONTENT BEGINS -->
				<div class="row">
					<div class="col-xs-12">
						<table id="sample-table-1" class="table table-striped table-bordered table-hover">
							<thead>
								<tr>
									<th>学号</th>
									<th>姓名</th>
									<th>性别</th>
									<th>联系电话</th>
									<th>电子邮箱</th>
									<th>联系地址</th>
									<th>出生日期</th>
									<th>操作</th>
								</tr>
							</thead>

							<tbody>
							<c:forEach items="${userList }" var="user">
								<tr>
									<td>${user.userId }</td>
									<td>${user.userName }</td>
									<c:if test="${user.gender==0 }">
									<td>男</td>
									</c:if>
									<c:if test="${user.gender==1 }">
									<td>女</td>
									</c:if>
									<td>${user.tel }</td>
									<td>${user.email }</td>
									<td>${user.address }</td>
									<td>${user.birthday }</td>
									<td>
									<a href="edit/${user.userId }"><button class="btn btn-xs btn-primary"><i class="ace-icon fa fa-pencil bigger-120"></i></button></a>
									<a href="delete/${user.userId }" class="del"><button class="btn btn-xs btn-primary"><i class="ace-icon fa fa-trash-o" ></i></button></a>
									</td>
								</tr>
							</c:forEach>

							</table>
						</div>
					</div>
				</div>
				
				<!-- 批量增加学生 -->
				<div class="modal fade" id="uploadFileModal" tabindex="-1" role="dialog" aria-labelledby="showTestModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
									&times;
								</button>
								<h4 class="modal-title" id="showTestModalLabel">
									上传
								</h4>
							</div>
							<div class="modal-body">
								<input id="uploadFile" name="uploadFile" type="file"/>
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-default" data-dismiss="modal">关闭
								</button>
								<button id="subjectStudentSaveBtn" type="button" class="btn btn-primary">
									保存
								</button>
							</div>
						</div><!-- /.modal-content -->
					</div><!-- /.modal -->
				</div>
				
				
				<div id="modal-table" class="modal fade" tabindex="-1">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-header no-padding">
								<div class="table-header">
									<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
										<span class="white">&times;</span>
									</button>
									Results for "Latest Registered Domains
								</div>
							</div>

							<div class="modal-body no-padding">
								<table class="table table-striped table-bordered table-hover no-margin-bottom no-border-top">
									<thead>
										<tr>
											<th>Domain</th>
											<th>Price</th>
											<th>Clicks</th>

											<th>
												<i class="ace-icon fa fa-clock-o bigger-110"></i>
												Update
											</th>
										</tr>
									</thead>

									<tbody>
										<tr>
											<td>
												<a href="#">ace.com</a>
											</td>
											<td>$45</td>
											<td>3,330</td>
											<td>Feb 12</td>
										</tr>

										<tr>
											<td>
												<a href="#">base.com</a>
											</td>
											<td>$35</td>
											<td>2,595</td>
											<td>Feb 18</td>
										</tr>

										<tr>
											<td>
												<a href="#">max.com</a>
											</td>
											<td>$60</td>
											<td>4,400</td>
											<td>Mar 11</td>
										</tr>

										<tr>
											<td>
												<a href="#">best.com</a>
											</td>
											<td>$75</td>
											<td>6,500</td>
											<td>Apr 03</td>
										</tr>

										<tr>
											<td>
												<a href="#">pro.com</a>
											</td>
											<td>$55</td>
											<td>4,250</td>
											<td>Jan 21</td>
										</tr>
									</tbody>
								</table>
							</div>

							<div class="modal-footer no-margin-top">
								<button class="btn btn-sm btn-danger pull-left" data-dismiss="modal">
									<i class="ace-icon fa fa-times"></i>
									Close
								</button>

								<ul class="pagination pull-right no-margin">
									<li class="prev disabled">
										<a href="#">
											<i class="ace-icon fa fa-angle-double-left"></i>
										</a>
									</li>

									<li class="active">
										<a href="#">1</a>
									</li>

									<li>
										<a href="#">2</a>
									</li>

									<li>
										<a href="#">3</a>
									</li>

									<li class="next">
										<a href="#">
											<i class="ace-icon fa fa-angle-double-right"></i>
										</a>
									</li>
								</ul>
							</div>
						</div><!-- /.modal-content -->
					</div><!-- /.modal-dialog -->
				</div><!-- PAGE CONTENT ENDS -->
			</div><!-- /.col -->
		</div><!-- /.row -->
	</body>
</html>